#include "stomped_reality/Game.h"
#include "stomped_reality/os/SystemMessageProcessor.h"
#include "stomped_reality/render_system/RenderSystem.h"
#include <X11/Xlib.h>
#include <assert.h>
void StompedReality::Core::SystemMessageProcessor::Initialize( )
{
}

bool StompedReality::Core::SystemMessageProcessor::Update( )
{
  assert( this->m_Game->RenderSystem( ) != 0 );
  assert( this->m_Game->RenderSystem( )->GetDisplayPointer( ) != 0 );
  XEvent xev;
  while ( XPending ( (Display*)(this->m_Game->RenderSystem( )->GetDisplayPointer( ) ) ) ) {
    XNextEvent( (Display*)(this->m_Game->RenderSystem( )->GetDisplayPointer( ) ), &xev );
    if (xev.type == ConfigureNotify)
    {
      this->m_Game->RenderSystem( )->Resize( xev.xconfigure.width, xev.xconfigure.height );
    }
    if (xev.type == ClientMessage) {
      this->m_Game->RenderSystem( )->CloseWindow( );
      return false;
    }
    this->ProcessMsg( &xev );
  }
  return true;
}

